import 'package:json_annotation/json_annotation.dart';
import 'package:smart_devices/utils/colors.dart';

part 'upkeep_task.g.dart';

@JsonSerializable()
class UpkeepTaskModel {
  /// 标题
  String title;

  /// 维修号
  String taskNo;

  /// 设备名称
  String name;

  /// 设备编号
  String code;

  /// 设备存放位置
  String location;

  /// 新增时间
  String addTime;

  UpkeepDegreeEnum? degree;

  UpkeepTaskEnum? task;

  UpkeepTaskModel(
      {required this.title,
      required this.taskNo,
      required this.name,
      required this.code,
      required this.location,
      required this.addTime,
      this.degree,
      this.task});

  factory UpkeepTaskModel.fromJson(Map<String, dynamic> json) =>
      _$UpkeepTaskModelFromJson(json);

  Map<String, dynamic> toJson() => _$UpkeepTaskModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

enum UpkeepDegreeEnum {
  slow(1, '低'),
  mid(2, '中'),
  fast(3, '急');

  final int value;
  final String label;

  const UpkeepDegreeEnum(this.value, this.label);
}

enum UpkeepTaskEnum {
  task(1, '保养任务', ColorsUtils.color2ba4);

  final int value;
  final String label;
  final String color;

  const UpkeepTaskEnum(this.value, this.label, this.color);
}
